/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Winner
 */
@Entity
@Table(name = "tblOrder")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TblOrder.findAll", query = "SELECT t FROM TblOrder t"),
    @NamedQuery(name = "TblOrder.findByOdID", query = "SELECT t FROM TblOrder t WHERE t.odID = :odID"),
    @NamedQuery(name = "TblOrder.findByOdCity", query = "SELECT t FROM TblOrder t WHERE t.odCity = :odCity"),
    @NamedQuery(name = "TblOrder.findByOdCountry", query = "SELECT t FROM TblOrder t WHERE t.odCountry = :odCountry"),
    @NamedQuery(name = "TblOrder.findByOdTotal", query = "SELECT t FROM TblOrder t WHERE t.odTotal = :odTotal"),
    @NamedQuery(name = "TblOrder.findByOdCreated", query = "SELECT t FROM TblOrder t WHERE t.odCreated = :odCreated"),
    @NamedQuery(name = "TblOrder.findByOdStatus", query = "SELECT t FROM TblOrder t WHERE t.odStatus = 0"),
    @NamedQuery(name = "TblOrder.findByUser", query = "SELECT t FROM TblOrder t WHERE t.usID.usID=:usID"),
    @NamedQuery(name = "TblOrder.findByDateOdCreated", query = "SELECT t FROM TblOrder t WHERE t.odCreated >= :dateStart AND t.odCreated <= :dateEnd ORDER BY t.odCreated DESC")})
public class TblOrder implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "odID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer odID;
    @Basic(optional = false)
    @Size(min = 1, max = 20)
    @Column(name = "odCity")
    private String odCity;
    @Basic(optional = false)
    @Size(min = 1, max = 20)
    @Column(name = "odCountry")
    private String odCountry;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "odTotal")
    private Double odTotal;
    @Basic(optional = false)
    @NotNull
    @Column(name = "odCreated")
    @Temporal(TemporalType.TIMESTAMP)
    private Date odCreated;
    @Column(name = "odStatus")
    private Integer odStatus;
    @OneToMany(mappedBy = "odID")
    private List<TblComplaint> tblComplaintList;
    @JoinColumn(name = "usID", referencedColumnName = "usID")
    @ManyToOne
    private TblUser usID;
    @JoinColumn(name = "mnID", referencedColumnName = "mnID")
    @ManyToOne
    private TblManager mnID;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tblOrder")
    private List<TblOrderDetail> tblOrderDetailList;
    @OneToMany(mappedBy = "odID")
    private List<TblProject> tblProjectList;

    public TblOrder() {
    }

    public TblOrder(Integer odID) {
        this.odID = odID;
    }

    public TblOrder(Integer odID, String odCity, String odCountry, Date odCreated) {
        this.odID = odID;
        this.odCity = odCity;
        this.odCountry = odCountry;
        this.odCreated = odCreated;
    }

    public Integer getOdID() {
        return odID;
    }

    public void setOdID(Integer odID) {
        this.odID = odID;
    }

    public String getOdCity() {
        return odCity;
    }

    public void setOdCity(String odCity) {
        this.odCity = odCity;
    }

    public String getOdCountry() {
        return odCountry;
    }

    public void setOdCountry(String odCountry) {
        this.odCountry = odCountry;
    }

    public Double getOdTotal() {
        return odTotal;
    }

    public void setOdTotal(Double odTotal) {
        this.odTotal = odTotal;
    }

    public Date getOdCreated() {
        return odCreated;
    }

    public void setOdCreated(Date odCreated) {
        this.odCreated = odCreated;
    }

    public int getOdStatus() {
        return odStatus;
    }

    public void setOdStatus(int odStatus) {
        this.odStatus = odStatus;
    }

    @XmlTransient
    public List<TblComplaint> getTblComplaintList() {
        return tblComplaintList;
    }

    public void setTblComplaintList(List<TblComplaint> tblComplaintList) {
        this.tblComplaintList = tblComplaintList;
    }

    public TblUser getUsID() {
        return usID;
    }

    public void setUsID(TblUser usID) {
        this.usID = usID;
    }

    public TblManager getMnID() {
        return mnID;
    }

    public void setMnID(TblManager mnID) {
        this.mnID = mnID;
    }

    @XmlTransient
    public List<TblOrderDetail> getTblOrderDetailList() {
        return tblOrderDetailList;
    }

    public void setTblOrderDetailList(List<TblOrderDetail> tblOrderDetailList) {
        this.tblOrderDetailList = tblOrderDetailList;
    }

    @XmlTransient
    public List<TblProject> getTblProjectList() {
        return tblProjectList;
    }

    public void setTblProjectList(List<TblProject> tblProjectList) {
        this.tblProjectList = tblProjectList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (odID != null ? odID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblOrder)) {
            return false;
        }
        TblOrder other = (TblOrder) object;
        if ((this.odID == null && other.odID != null) || (this.odID != null && !this.odID.equals(other.odID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.aptech.entities.TblOrder[ odID=" + odID + " ]";
    }
}
